package com.etoak.rst.sys.employee.service.serviceimpl;

import com.etoak.rst.sys.employee.Dto.EmpDTO;
import com.etoak.rst.sys.employee.entity.Employee;
import com.etoak.rst.sys.employee.mapper.EmployeeMapper;
import com.etoak.rst.sys.employee.service.IEmployeeService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class EmployeeServiceImpl implements IEmployeeService {

    @Autowired
    EmployeeMapper dao;

    @Override
    public List<Employee> querySome(EmpDTO dto) {
        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        return dao.querySome(dto);
    }

    @Override
    public boolean addEmp(Employee emp) {
        emp.setCreateTime(new Date());
        emp.setUpdateTime(new Date());
        return dao.addEmp(emp)>0;
    }

    @Override
    public boolean delEmp(int eid) {
        return dao.delEmp(eid)>0;
    }

    @Override
    public boolean upEmp(Employee emp) {
        emp.setUpdateTime(new Date());
        return dao.upEmp(emp);
    }
}
